﻿using Microsoft.AspNetCore.Http;
using NDLS.WebApi.Model.ModelVM;
using RZWH.WebApi.IServices;
using RZWH.WebApi.Model;
using RZWH.WebApi.Model.DBmodels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace RZWH.WebApi.Services
{
    public class PhoneService : IPhoneService
    {
        public MsgRes addPhone(Smartphone phone)
        {
            using (var context = new FluffypawmediaContext())
            {
                try
                {
                    context.Smartphones.Add(phone);
                    context.SaveChanges();
                    return new MsgRes { Status = "Success", Msg = "添加成功" };
                }
                catch
                {
                    return new MsgRes { Status = "Error", Msg = "添加失败" };
                }
            }
        }

        public MsgRes UploadImage(IFormFile file)
        {
            if (file == null || file.Length == 0)
                return new MsgRes{ Status = "Error", Msg = "File is not selected or is empty."};

            throw new NotImplementedException();
        }
    }
}
